import Vue from 'vue'
import App from './App.vue'
import router from '@/router'
import store from './store'

//引入mock
import '@/mock/mockServe'

//定义三级联动组件后注册为全局组件
import TypeNav from '@/components/TypeNav'
Vue.component(TypeNav.name, TypeNav)

//swiper轮播图
import 'swiper/css/swiper.css'
import Carsousel from '@/components/Carsousel'
Vue.component(Carsousel.name, Carsousel)

// 分页器
import Pagination from '@/components/Pagination'
Vue.component(Pagination.name, Pagination)

import { reqCategoryList } from '@/api'
reqCategoryList();

// 同意引入
import * as API from '@/api'

// 引入加载图片
import atm from '@/assets/jiazai.webp'
// 引入图片懒加载插件
import VueLazyload from 'vue-lazyload'
// 注册插件
Vue.use(VueLazyload, {
  // 懒加载默认图片
  loading: atm
})

// 自定义插件
import myPlugins from '@/plugins/myPlugins'
Vue.use(myPlugins, { name: 'upper' })

Vue.config.productionTip = false
new Vue({
  render: h => h(App),
  // 全局事件总线
  beforeCreate() {
    Vue.prototype.$bus = this;
    Vue.prototype.$API = API;
  },
  router,
  // 在这里注册router后，所有组件都有$router和$route属性
  store,
}).$mount('#app')
